<template>
  <!-- 真实页面仅在登录成功或者非生产模式下的非微信环境中显示或者在PC编辑环境下显示 -->
  <div id="app">
    <router-view />
    <!--  页面过渡，小人跑步 -->
    <loading-com v-show="loading"></loading-com>
  </div>
  <!-- 非微信环境警告 -->
  <!-- <div v-else-if="!$env.isWX">
    <error-page emptyImg="empty-wx-login"
                imgWidth="200"
                imgHeight="200"
                type="none">
      <div class="wx-login-tip">
        请在微信客户端打开链接({{version}})
      </div>
    </error-page>
  </div> -->
</template>

<script>
  import Vue from 'vue'
  import loadingCom from '@/components/loading'

  import {
    mapState
  } from 'vuex'
  const computed = mapState({
    loading: 'loading'
  })
  export default {
    name: 'App',
    data () {
      return {
        isFirst: true
      }
    },
    watch: {
      $route (to) {
        let route = this.$route
        // 自动分享
        if (!route.meta.noAutoShare) {
          Vue.prototype.$wxShare({
            link: window.location.origin
          })
        }
        if (to.name !== 'register') {
          // if(this.user)
          // console.error()
          let userStr = this.$cache.getCache('userinfo')
          if (userStr) {
            let user = JSON.parse(userStr)
            if (user && !user.phone) {
              this.$router.push({name: 'register'})
            }
          }
        }
      }
    },
    components: {
      loadingCom
    },
    computed
  }
</script>
<style lang="stylus" scoped>
#app {
  width: 100vw;
}

* {
  padding: 0;
  margin: 0;
  list-style: none;
  font-style: normal;
  text-decoration: none;
  border: none;
  font-family: 'PingFangSC-Regular';
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;

  &:hover {
    outline: none;
  }
}

.wx-login-tip {
  margin-top: 51px;
  font-size: 34px;
  color: rgba(51, 51, 51, 1);
}
</style>
